package com.hp.tiger.concurrent.classloader.chapter1;

/**
 * @author XavierDong
 **/
public class Singleton {


    /**
     * 初始化
     * <p>
     * instance = null;
     * int x = 0;
     * int y = 0;
     * <p>
     * instance = new Singleton();
     * x++=>x=1
     * y++=>y=1
     * <p>
     * int x = 0;
     * y = 1;
     */
    private static Singleton singleton = new Singleton();


    public static int x = 0;
    public static int y;

    private Singleton() {
        x++;
        y++;
    }

    /**
     * 初始化
     * <p>
     * int x = 0;
     * int y = 0;
     * instance = null;
     */
//    private static Singleton singleton = new Singleton();
    public static Singleton getInstance() {
        return singleton;
    }

    public static void main(String[] args) {
//        Singleton singleton = getInstance();
        System.out.println(Singleton.x);
        System.out.println(Singleton.y);
    }
}



